package com.ler.yrmall.webapp.controller;

import cn.hutool.core.lang.Assert;
import com.ler.yrmall.aspect.anno.AccessRecord;
import com.ler.yrmall.basic.Result;
import com.ler.yrmall.webapp.service.YuruoAuthService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author Leron
 * @version 1.0
 */
@AccessRecord
@RestController
@RequestMapping("/auth")
public class AuthController {

    @Resource
    private YuruoAuthService authService;

    @GetMapping("/token/{code}")
    public Result<?> getToken(@PathVariable String code) {
        Assert.notBlank(code,() -> new RuntimeException("授权码不能为空"));
        return Result.ok(authService.getToken(code));
    }

}
